<script setup lang="ts">
import { useCapital } from "@/stores/capital";
import { computed, ref, watch } from "vue";
import JInput from "@/components/j-input/index.vue";
import CoinList from "@/components/coin-list/index.vue";
import { useTokens } from "@/stores/tokens";
const capital = useCapital();
const tokens = useTokens();

// const curItem = ref<any>();

// const list = computed(() => {
//     return capital.blockBalanceList;
// })
// watch(() => capital.blockBalanceList, (newVal: any, oldVal: any) => {
//     console.log("capital.blockBalanceList", capital.blockBalanceList)
//     curItem.value = newVal[0];
// })

const curItem = computed(() => capital.curblockBalance);
const onChange = (val: any) => {
    // curItem.value = val;
    console.log(val);
    capital.changeCurblockBalance(val);
};
const list = computed(() => {
    if (capital.blockBalanceList && capital.blockBalanceList.length) {
        return capital.blockBalanceList;
    }
    return [];
});

const getImg = (item: any) => {
    return tokens.getImgByHash(item.contractAddress);
};
</script>
<template>
    <CoinList :cur-item="curItem" :list="list" @choose="onChange" :is-all="false" key-word="name"></CoinList>
</template>
<style lang="scss" scoped></style>
